<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>点击获取</button>
    <script>
      var butEle = document.querySelector("button");
      butEle.onclick = function () {
        var res = decodeURI(window.location.search);
        // console.log(res);
        res = res.substr(1);
        // console.log(res);
        var arr = res.split("&");
        // console.log(arr);
        var obj = {};
        arr.forEach(function (item) {
          var newarr = item.split("=");
          obj[newarr[0]] = newarr[1];
        });
      };
      console.log(obj);
    </script>
  </body>
</html>
